package com.webdesign.dao.jdbc;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class TbAnnounceSQL {
	
	/*
	 * Miner 取得tbannounce表格的id的最大值，返回类型为Integer
	 */
	public Integer getMaxAnnounceId(){
		Connection conn = null;
		Statement stmt = null;
		ResultSet rs = null;
		String strs = null;
		Integer maxId = 0;
		try {
			conn = DBConnection.getConnection();
			stmt = conn.createStatement();
			rs = stmt.executeQuery("select Id as Id from tb_announce");
			while (rs.next()) {
				strs=rs.getString("Id");
				if(Integer.parseInt(strs) > maxId){
					maxId = Integer.parseInt(strs);
				}
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return maxId;
	}
}
